# from django.contrib import admin
# from django.core.cache import cache
# from apps.goods.models import Goods, GoodsSKU, GoodsType, GoodsImage, IndexGoodsBanner, IndexTypeGoodsBanner, \
#     IndexPromotionBanner
#
#
# # Register your models here.
# class BaseModelAdmin(admin.ModelAdmin):
#     """公共管理模型类的抽取"""
#
#     def save_model(self, request, obj, form, change):
#         """新增或者更新表中的数据时调用"""
#         super().save_model(request, obj, form, change)
#
#         # 发出任务,让celery worker 重新生成首页静态文件
#         from celery_tasks.tasks import generate_static_index_html
#         generate_static_index_html.delay()
#
#         # 清除首页的缓存数据
#         context = cache.get('index_page_data')
#         while context is not None:
#             cache.delete('index_page_data')
#             context = cache.get('index_page_data')
#
#     def delete_model(self, request, obj):
#         '''删除表中的数据时调用'''
#         super().delete_model(request, obj)
#         # 发出任务，让celery worker重新生成首页静态页
#         from celery_tasks.tasks import generate_static_index_html
#         generate_static_index_html.delay()
#
#         # 清除首页的缓存数据
#         context = cache.get('index_page_data')
#         while context is None:
#             cache.delete('index_page_data')
#             context = cache.get('index_page_data')
#
#
# class IndexPromotionBannerAdmin(BaseModelAdmin):
#     """首页促销活动模型管理模型类"""
#     pass
#
#
# class GoodsTypeAdmin(BaseModelAdmin):
#     """商品类型模型管理模型类"""
#     pass
#
#
# class IndexGoodsBannerAdmin(BaseModelAdmin):
#     """首页轮播商品展示模型管理模型类"""
#     pass
#
#
# class IndexTypeGoodsBannerAdmin(BaseModelAdmin):
#     """首页分类商品展示模型管理模型类"""
#     pass
#
#
# admin.site.register(Goods)  # 商品SPU模型类
# admin.site.register(GoodsSKU)  # 商品SKU模型类
# admin.site.register(GoodsImage)  # 商品图片模型类
# admin.site.register(GoodsType, GoodsTypeAdmin)  # 商品类型模型类
# admin.site.register(IndexTypeGoodsBanner, IndexTypeGoodsBannerAdmin)  # 首页分类商品展示模型类
# admin.site.register(IndexPromotionBanner, IndexPromotionBannerAdmin)  # 首页促销活动模型类'
# admin.site.register(IndexGoodsBanner, IndexGoodsBannerAdmin)  # 首页轮播商品展示模型类
